import { BaseWindow } from "../../../component/window/BaseWindow";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GButton } from "../../../../com/mui/controls/GButton";
import { WindowEvent } from "../../../component/window/WindowEvent";
import { DataEvent } from "../../events/DataEvent";
import { GModuleEvent } from "../../mvc/GModuleEvent";
import { ItemData } from "../../resource/info/ItemData";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { _itemData } from "../../../../this/_itemData";
//class TradeSellNumWin
    
    export  class TradeSellNumWin extends BaseWindow
    {
        constructor()
        {
            super();
            this.titleHeight = 30;
            this.width = 240;
            this.height = 150;
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc2=null;
            super.createChildren();
            var loc1=new GTextFiled();
            loc1.x = 45;
            loc1.y = 45;
            loc1.selectable = false;
            loc1.width = 150;
            loc1.height = 20;
            loc1.htmlText = "<font color=\'#ffffff\' size=\'13\'>" + Language.getString(41018) + "</font>";
            this.addChild(loc1);
            this.sellNumInput = ObjCreate.createGTextInput(50, 73, 133, 20, this);
            this.sellNumInput.restrict = "0-9";
            loc2 = new GButton();
            loc2.label = Language.getString(41019);
            loc2.styleName = "Button";
            loc2.width = 47;
            loc2.height = 22;
            loc2.x = 45;
            loc2.y = 103;
            loc2.addEventListener(flash.events.MouseEvent.CLICK, this.ComfirmHandler);
            this.addChild(loc2);
            var loc3=new GButton();
            loc3.label = Language.getString(41020);
            loc3.styleName = "Button";
            loc3.width = 49;
            loc3.height = 22;
            loc3.x = 145;
            loc3.y = 103;
            loc3.addEventListener(flash.events.MouseEvent.CLICK, this.CancelHandler);
            this.addChild(loc3);
            this.addEventListener(WindowEvent.CLOSE, this.CloseHandler);
            return;
        }

        /* internal  */ComfirmHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this._itemData) 
            {
                this.hide();
                return;
            }
            var loc1=int(this.sellNumInput.text);
            if (loc1 > this._itemData.itemAmount) 
            {
                loc1 = this._itemData.itemAmount;
            }
            dispatchEvent(new DataEvent(GModuleEvent.Event_SellNum, {"itemData": _itemData, "amount": loc1}, false, true));
            this._itemData = null;
            this.hide();
            return;
        }

        /* internal  */CancelHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            dispatchEvent(new DataEvent(GModuleEvent.Event_SellNum, {"itemData": _itemData, "amount": 0}, false, true));
            this._itemData = null;
            this.hide();
            return;
        }

        /* internal  */CloseHandler(arg1: WindowEvent): void
        {
            if (this._itemData != null) 
            {
                dispatchEvent(new DataEvent(GModuleEvent.Event_SellNum, {"itemData": _itemData, "amount": 0}, false, true));
                this._itemData = null;
            }
            return;
        }

        public showWin(arg1: ItemData): void
        {
            this._itemData = arg1;
            this.sellNumInput.text = String(this._itemData.itemAmount);
            this.show();
            return;
        }

        /* internal */ /* var */sellNumInput: GTextInput;

        /* internal */ /* var */_itemData: ItemData;
    }
